home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / rl / data / bin / test-db-files < prev    next >
Encoding:
Text File  |  2000-10-02  |  3.8 KB  |  134 lines

  1. #!/bin/sh
  2. # test-db-files
  3. # copyleft (c) 2000, joseph cheek, joseph@cheek.com.  released under GPL.
  4. # test-db-files:
  5. # test the validity of the files $BUILDROOT/col/data/{pkgs|meta}.db.  a
  6. # real script would build these files instead of testing them, but i
  7. # expect little in these files will change and i don't want to put the
  8. # effort into building them.  this script will instead just tell you when
  9. # you updated an RPM and forgot to change these files, or when their
  10. # contents just don't jive.
  11. # $1 = RPMDIR
  12. # $2 = pkgs.db pathlist
  13. # $3 = meta.db pathlist
  14. # ex: ./test-db-files ../../../../col24_gold/col/install/RPMS/ ../pkgs.db \
  15. #     ../meta.db
  16. # these files contain a list of packages and package groups for selection
  17. # during a lisa install.
  18. # each time the RPM list changes, this file needs to be checked.  in
  19. # practice it should be checked for each build IMHO.
  20.  
  21. # the pkgs.db file format is as follows [educated guess]:
  22. # GROUP:NAME:n:DRO:INST_SIZE:CAT:RPM_SIZE:VER:: [note 2 trailing colons]
  23. # where:
  24. # GROUP        = low-level group name, ie TEXTTOOL or SHELL or REC
  25. # NAME        = name of the RPM, ie DEV, SysVinit, XFree86-3DLabs
  26. # n        = dunno.  always n.
  27. # DRO        = not sure.  Default, Recommended, Optional?
  28. # INST_SIZE = size of package once installed.  from rpm.
  29. # CAT        = one of eleven different [arbitrary?] categories.
  30. #           currently used are:
  31. #         basis1     = basic stuff, needs to be installed
  32. #         develop1 = development stuff
  33. #         doku1     = documentation stuff
  34. #         misc1      = misc stuff
  35. #         network1 = network stuff
  36. #         tex1     = tex packages, not sure why it's separate
  37. #         text1     = text processing stuff
  38. #         xappl1     = X apps
  39. #         xbasis1     = basic X stuff
  40. #         xdevelo1 = X development stuff
  41. #         xemacs1  = X [lucid?] emacs stuff, not sure why separate
  42. # RPM_SIZE  = the size of the [uninstalled] rpm package.
  43. # VER        = version and revision of the package, ie 3.3.6-3
  44. # the meta.db file format is as follows [educated guess]:
  45. # :HIGHGROUP:GROUP: [note leading colon]
  46. # where:
  47. # HIGHGROUP = high-level group name, ie MAIN or TEXT or X or NET
  48. # GROUP        = low-level group name from pkgs.db, ie TEXTTOOL or SHELL or REC
  49.  
  50. # pkgs.db tests:
  51. # TEST 1: make sure each GROUP is listed in meta.db
  52. # TEST 2: make sure each NAMEd rpm exists in the RPM dir
  53. # TEST 3: make sure each rpm in the RPM dir exists as a NAME
  54.  
  55. if [ "$#" != "3" ]; then
  56.   echo -e `basename $0`: need 3 parameters\\a
  57.   exit 1
  58. fi
  59.  
  60. TMPFILE=/tmp/`basename $0`.$$
  61.  
  62. # TEST 1: make sure each pkgs.db GROUP is listed in meta.db
  63. echo TEST 1: make sure each pkgs.db GROUP is listed in meta.db
  64.  
  65. for a in `cut -d : -f 1 "$2" | sort | uniq`
  66. do
  67.  
  68.   grep :$a:$ "$3" > /dev/null
  69.   if [ "$?" = "1" ]; then
  70.     echo -e $a is not listed in $3\\a
  71.     TEST_FAIL=1
  72.   fi
  73.  
  74. done
  75.  
  76. # TEST 2: make sure each pkgs.db NAMEd rpm exists in the RPM dir
  77. echo TEST 2: make sure each pkgs.db NAMEd rpm exists in the RPM dir
  78.  
  79. # extract RPM names and versions
  80. ( while read a
  81.   do
  82.  
  83.     RPM_NAME=`echo $a | cut -d : -f 2`
  84.     RPM_VERS=`echo $a | cut -d : -f 8`
  85.  
  86.     if [ ! -e "$1/$RPM_NAME-$RPM_VERS.i386.rpm" -a \
  87.          ! -e "$1/$RPM_NAME-$RPM_VERS.i486.rpm" -a \
  88.          ! -e "$1/$RPM_NAME-$RPM_VERS.i586.rpm" -a \
  89.          ! -e "$1/$RPM_NAME-$RPM_VERS.noarch.rpm" ]
  90.     then
  91.       echo -e RPM $RPM_NAME-$RPM_VERS does not exist\\a
  92.       TEST_FAIL=1
  93.     fi
  94.  
  95.   done ) < "$2"
  96.  
  97. # TEST 3: make sure each rpm in the RPM dir exists as a pkgs.db NAME
  98. echo TEST 3: make sure each rpm in the RPM dir exists as a pkgs.db NAME
  99.  
  100. # generate list of rpm names
  101.  
  102.   for a in "$1"/*.rpm
  103.   do
  104.  
  105.     RPM_NAME=`rpmextr --tag=name "$a"`
  106.     RPM_VERS=`rpmextr --tag=version "$a"`-`rpmextr --tag=release "$a"`
  107.  
  108.     grep ":$RPM_NAME:.*:$RPM_VERS:" "$2" > /dev/null
  109.     if [ "$?" = "1" ]
  110.     then
  111.       echo -e RPM $RPM_NAME-$RPM_VERS [from file $a] does not exist in pkgs.db\\a
  112.       TEST_FAIL=1
  113.     fi
  114.  
  115.   done
  116.  
  117. if [ "$TEST_FAIL" = "1" ]
  118. then
  119.   exit 1
  120. fi
  121.